<?php 

function checkValid($connection,$table,$field,$sample)
{
	$query = "SELECT $field FROM $table where $field LIKE '$sample'";
	$line_number = pg_num_rows(pg_query($connection,$query));
	if($line_number>0) return TRUE;
	else return FALSE;	  
}

?>
